srchr/search

  • constructor
inherits: can.Control

new SearchControl(element, options) listens to a search form being submitted and updates currentSearch with a new [srchr/models/search Search] instance.

new srchr.search(element, options)

new SearchControl(element, options) listens to a search form being submitted and updates currentSearch with a new [srchr/models/search Search] instance.

Parameters

  1. element {HTMLElement}

    the element to show results within.

  2. options {Object}

    An object of the following options:

    defaultText {String}

    The placeholder text.

    currentSearch {can.compute}

    The current search that should be performed.

If another module (ex: srchr/history) changes currentSearch, SearchControl will update the search form accordingly.

Other features of SearchControl include:

  • basic placeholder functionality
  • search validation

Example:

var currentSearch = can.compute();

new SearchControl("#search",{
  currentSearch: currentSearch,
  defaultText: "Enter search text"
})